<?php
if(@$_POST['open'] != 'please'){
	exit;
}
include_once("../../php/include_all.php");
?>
<div class="row-fluid">
	<div class="span12">
		<div class="widget">
			<div class="widget-title" style="margin-top: 20px;">
                <h4><i class="icon-reorder"></i>Pilih Laporan</h4>
                <span class="tools">
                    <a href="javascript:;" class="icon-chevron-down"></a>
                </span>
            </div>
			<div class="widget-body form">
				<form id="form-bidang" method="POST" action="" class="form-horizontal">
					<input type="hidden" name="act" value="cari">
					<input type="hidden" id="id_bidang" name="id_bidang" value="0">
					<div class="control-group">
                        <label class="control-label">Bidang</label>
                        <div class="controls">
                            <select name="id_bidangcb" id="id_bidangcb">
								<option id="awal">Pilih salah satu</option>
								<?php
									$bidang = get_datas('SELECT * FROM spm_bidang_urusan');
									foreach($bidang as $bidang){
								?>
									<option value="<?php echo $bidang['id_bidang'] ?>"><?php echo $bidang['nama_bidang'] ?></option>
								<?php
								}
								?>
							</select>
                        </div>
					</div>
					<div class="control-group">
                        <label class="control-label">Tahun Anggaran</label>
                        <div class="controls">
                            <select name="id_tahun" id="id_tahun">
								<option id="awal">Pilih salah satu</option>
								<?php
									$tahun = get_datas('SELECT DISTINCT t.thn_angg, t.id_thn_angg FROM spm_thn_angg t, spm_jenis_pelayanan i WHERE t.id_thn_angg = i.id_thn_angg');
									foreach($tahun as $thn){
								?>
									<option value="<?php echo $thn['id_thn_angg'] ?>"><?php echo $thn['thn_angg'] ?></option>
								<?php
								}
								?>
							</select>
                        </div>
					</div>
					<span id='alerti' style='margin-left: 13px;padding-bottom:3px;'></span>
					<div class="form-actions">
                        <button type="button" class="btn btn-primary btn-cari" onclick="laporan()">Cari</button>
                        <span id="result"></span>
                    </div>
				</form>
			</div>
		</div>
	</div>
	<div class="row-fluid">
        <div class="span12">
			<div class="widget" style="">
				<div class="widget-body">
					
                    <table class="table table-striped table-bordered" id="sample_1">
                    <thead>
                        <tr>
                            <th class="hidden-phone" style="width:50px; text-align:center;">No</th>
                            <th colspan="2" style="text-align:center;">Pelayanan / Indikator</th>
							<th style="text-align:center; width:100px;">Standart Nilai</th>
							<th style="text-align:center; width:100px;">Batas Waktu</th>
							<th style="text-align:center; width:80px;">Capaian</th>
							<th style="text-align:center; width:80px;">Selisih</th>
                        </tr>
                    </thead>
                    <tbody id="tbody-laporan">
					
					</tbody>
					</table>
					<div style="margin:10px;" class="pull-right">
						<a style="margin:10px;" class="btn btn-primary" href="laporan_bidang/printXLS.php?b=&t=" id='printxls' target="_blank"><i class="icon-print"></i>&nbsp;Cetak Excel</a>
						<a class="btn btn-primary" href="laporan_bidang/printPHP.php?b=&t=" id='printpdf' target="_blank"><i class="icon-print"></i>&nbsp;Cetak PDF</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
    jQuery(document).ready(function() {       
         // initiate layout and plugins
        App.init();
    });
	
</script>	
<script>
var url = 'laporan_bidang/laporan_action.php';
function laporan(){
	var btn = $(this);
	var bidang = $('#id_bidangcb').val();
	var tahun = $('#id_tahun').val();
	
	var post = $.post(url, {act: 'tmpl_laporan', b:bidang, t:tahun});
	post.done(function(ok){
		var isi = ok.split('__');
		if(isi.length == 2){
			if(isi[0] == 'ok'){
				$('#tbody-laporan').html(isi[1]);
				$('#printpdf').attr('href','laporan_bidang/printPHP.php?b='+bidang+'&t='+tahun);
				$('#printxls').attr('href','laporan_bidang/printXLS.php?b='+bidang+'&t='+tahun);
			}else if(isi[0] == 'err'){
				$('#alerti').removeClass().addClass('alert alert-error');
				$('#alerti').html('Error !!!' + isi[1]);
				setTimeout(function(){
					$('alerti').removeClass();
				}, 1500);
			}
		} else{
			$('#alerti').removeClass().addClass('alert alert error');
			$('#alerti').html('Gagal Mengambil data ');
			setTimeout(function () {
				$('#alerti').removeClass();
				$('#alerti').html('');
			}, 1500);
		}
	});
}
</script>